<!-- 这是Header组件 -->
<template>
  <header>
    <div class="l-content">
      <el-button @click="handleMenu" plain icon="el-icon-menu" size="mini"></el-button>
      <el-breadcrumb>
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item :to="current.path" v-if="current">{{current.label}}</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="r-content">
      <el-dropdown @command="handleCommand" trigger="click" size="mini">
        <span class="el-dropdown-link">
          <img :src="userImg" alt="" class="user">
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>个人中心</el-dropdown-item>
          <el-dropdown-item command="logout">退出</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </header>
</template>

<script>
import { mapState } from 'vuex'
export default {
  data () {
    return {
      userImg: require("../assets/images/user.png")
    }
  },
  methods: {
    handleMenu () {
      this.$store.dispatch("handleMenu")
    },
    handleCommand (command) {
      console.log(command)
      this.$router.replace("/")
    }
  },
  computed: {
    ...mapState({
      current: (state) => state.tab.currentMenu
    })
  }
}
</script>

<style lang="scss" scoped>
  header {
    display: flex;
    height: 100%;
    justify-content: space-between;
    align-items: center
  }
  .l-content {
    display: flex;
    align-items: center;
    .el-button {
      margin-right: 20px;
    }
  }
  .r-content {
    .user {
      width: 40px;
      height: 40px;
      border-radius: 50%;
    }
  }
</style>

<style lang="scss">
.el-breadcrumb__item{
  .el-breadcrumb__inner {
    color: #666;
    font-weight: normal
  }
  &:last-child {
    .el-breadcrumb__inner {
      color: white
    }
  }
}

</style>
